package com.store.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.store.app.R;
import com.store.app.bean.HistoryBean;

import java.util.List;

public class CoupleHistoryAdapter extends BaseAdapter {
    private List<HistoryBean> historyBeanList;
    private Context context;


    public CoupleHistoryAdapter(List<HistoryBean> historyBeanList, Context context) {
        this.historyBeanList = historyBeanList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return historyBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return historyBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final HistoryBean historyBean = historyBeanList.get(position);
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_history, null);
            holder.tv_desc = (TextView) convertView.findViewById(R.id.tv_desc);
            holder.tv_date = (TextView) convertView.findViewById(R.id.tv_date);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv_desc.setText(historyBean.getRemark());
        holder.tv_date.setText(historyBean.getTracked_date());
        return convertView;
    }
    public  class ViewHolder {
        public TextView tv_desc;               //联系人
        public TextView tv_date;                //日期
    }
}
